package com.qf.day07.poly02;

/**
 * 矩形子类
 */

public class Rectangle extends TuXing {
    //矩形的长
    private double a;
    //矩形的宽
    private double b;

    @Override
    public double zc() {
        double zc = (a+b)*2;
        System.out.println(getName()+"的周长为:"+zc);
        return zc;
    }

    @Override
    public double area() {
        double area= a*b;
        System.out.println(getName()+"的面积为:"+area);
        return area;
    }

    public Rectangle() {
    }

    public Rectangle(String name, double a, double b) {
        super(name);
        this.a = a;
        this.b = b;
    }

    public double getA() {
        return a;
    }

    public void setA(double a) {
        this.a = a;
    }

    public double getB() {
        return b;
    }

    public void setB(double b) {
        this.b = b;
    }

    @Override
    public String toString() {
        return "Rectangle{" +
                "a=" + a +
                ", b=" + b +
                "} " + super.toString();
    }
}
